package org.wkg.lesson11;

import java.util.concurrent.CopyOnWriteArrayList;

public class Demo_1107 {
    public static void main(String[] args) {
        CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList();
        for (int i = 0; i < 10; i++) {
            int j = i + 1;
            Thread thread = new Thread(() -> {
                copyOnWriteArrayList.add(j);
                System.out.println(copyOnWriteArrayList);
            });
            thread.start();
        }
    }
}
